1537D - Deleting Divisors - CodeForces Solution


games math number theory *1700

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;

void init_code(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif // ONLINE_JUDGE
}
 
                             // MACROS

typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef priority_queue<int> maxheap;
typedef priority_queue<int, vector<int>, greater<int>> minheap;

#define ff first
#define ss second
#define pb push_back
#define FOR(i, a, b)  for(int i=a; i<=b; i++)
#define FORR(i, a, b)  for(int i=a; i>=b; i--)  
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define vlb(v, x) lower_bound(all(v), x)
#define vub(v, x) upper_bound(all(v), x)
#define slb(v, x) v.lower_bound(x)
#define sub(v, x) v.upper_bound(x)   
#define MOD 1000000007
#define MP make_pair

// Debugging
#ifndef ONLINE_JUDGE
#include "debug.cpp"
#else
#define dbg(x)
#endif
    
                        // FUNCTIONS
ll lcm(ll a, ll b){ ll res = (a*b)/__gcd(a,b); return res; }
ll binpow(ll a, ll b) { ll res = 1; while (b > 0) { if (b & 1) res = res * a; a = a * a; b >>= 1; } return res;}

                                // PRIMARY FUNCTION
/*
 think about hashing while comparing contiguous elements...
 try to think backward.. 
 if you arent able to come up for answer, try to fix some variable, some bits, initial starting point or end point.....
 may be break a operation into two or combine two into one
*/

void solve()
{
    ll n;
    cin >> n;
    
    if(n == 1){
        cout << "Bob\n";
        return;
    }

    FOR(i, 1, 31){
        if(n == (1ll<<i)){
            if(i&1){
                cout << "Bob\n";
            }
            else{
                cout << "Alice\n";
            }
            return;
        }
    }
    
    if(n&1){
        cout << "Bob\n";
    }
    else{
        cout << "Alice\n";
    }
}



 // MAIN FUNCTION
    
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    
    init_code();

    int t = 1;
    cin>>t;
    
    while(t--){
        solve();
    }
    
    return 0;
}


Comments

Submit
0 Comments
More Questions

1459B - Move and Turn
1006F - Xor-Paths
706C - Hard problem
304C - Lucky Permutation Triple
1301C - Ayoub's function
38E - Let's Go Rolling
171G - Mysterious numbers - 2
1183C - Computer Game
400C - Inna and Huge Candy Matrix
417A - Elimination
222A - Shooshuns and Sequence
1736A - Make A Equal to B
1736B - Playing with GCD
887C - Solution for Cube
1737C - Ela and Crickets
1741C - Minimize the Thickness
1741A - Compare T-Shirt Sizes
1741D - Masha and a Beautiful Tree
109B - Lucky Probability
1741B - Funny Permutation
1741E - Sending a Sequence Over the Network
344B - Simple Molecules
370A - Rook Bishop and King
546E - Soldier and Traveling
1741G - Kirill and Company
1200B - Block Adventure
1088B - Ehab and subtraction
1270B - Interesting Subarray
478C - Table Decorations
1304C - Air Conditioner